const aggregation = {
	methods:{
		//求和
		summation(list,conf){
			let sum = 0;
			let label=conf.statistics;
			list.filter(res=>{
				if(res[label]){
					sum = sum + res[label]
				}
			})
			return sum;
		},
		//平均值
		sumAvg(list,conf){
			let sum = 0;
			let label=conf.statistics;
			list.filter(res=>{
				if(res[label]){
					sum = sum + res[label]
				}
			})
			return sum/list.length;
		},
		//获取最小
		sumMin(list,conf){
			let sum = list[0][conf.statistics];
			let list_ = [];
			let label=conf.statistics;
			list.filter(res=>{
				if(sum>res[label]){
					sum = res[label];
				}
			})
			return sum;
		},
		//获取最大
		sumMax(list,conf){
			let sum = 0;
			let list_ = [];
			let label=conf.statistics;
			list.filter(res=>{
				if(sum<res[label]){
					sum = res[label];
				}
			})
			return sum;
		},
		//自定义
		customFormat(list,conf){
			let value=0;
			if(conf.format){
				let fn=new Function("value","list","conf" ,conf.format);
				let func=fn.bind(this);
				value=func(value,list,conf);
			}
			return value;
		},
	}
}
export default aggregation